<?php
class ModelDesignLayout extends Model {	
	public function getLayout($route) {
		$type = (int)$this->config->get('config_restaurant_id') > 0?'restaurant':'portal';
		
		$query = $this->db->query("SELECT lt.* FROM " . DB_PREFIX . "layout_route lt INNER JOIN " . DB_PREFIX . "layout l ON lt.layout_id = l.layout_id WHERE '" . $this->db->escape($route) . "' LIKE CONCAT(route, '%') AND l.type = '" . $type . "' ORDER BY route ASC LIMIT 1");
		
		if ($query->num_rows) {
			return $query->row['layout_id'];
		} else {
			return 0;	
		}
	}
}
?>